class bnum
{
	private:
		int *len,size;
		bool *f;
		char *dat;
	public:
		void init(){dat=new char[size+1];len=new int;f=new bool;memset(dat,'0',sizeof (*dat));(*f)=1;(*len)=0;}
		void del(){delete[] dat;delete len;delete f;}
		void reset(){del();init();}
		
		bnum(int siz=1001):size(siz){init();}
		bnum(const long long a,int siz=1001);
		bnum(const char * a,int siz=1001);
		bnum(const bnum &a,int siz=1001);
		bnum operator=(bnum  a);
		~bnum(){del();}
		
		void print();
		friend ostream & operator<<(ostream & out,bnum & a);
		friend istream & operator>>(istream & in,bnum & a);
		
		
		bnum  operator+(const bnum & a)const;
		bnum & operator+=(const bnum & a);
		bnum  operator-(const bnum & a)const;
		bnum & operator-=(const bnum & a);
		bnum  operator*(const bnum & a)const;
		bnum & operator*=(const bnum & a);
		bnum  operator/(const bnum & a)const;
		bnum & operator/=(const bnum & a);
		bnum  operator%(const bnum & a)const;
		bnum & operator%=(const bnum & a);
		
		bool operator>(bnum & a)const;
		bool operator<(bnum & a)const;
		bool operator>=(bnum & a)const;
		bool operator<=(bnum & a)const;
		bool operator==(bnum & a)const;
		
		bnum & operator<<(bnum & a)const;
		bnum & operator>>(bnum & a)const;
		bnum & operator<<=(bnum & a);
		bnum & operator>>=(bnum & a);
		
		bnum & operator&(bnum & a)const;
		bnum & operator|(bnum & a)const;
		bnum & operator^(bnum & a)const;
		bnum & operator~()const;
		
		int operator[](int & a)const{return dat[size-a+1]-'0';}
		
		bnum & sqrt(bnum & a)const;
		bnum & pow(bnum & a)const;
		
		int getlen()const{return (*len)+1;}
		
};